<?php defined('IN_IA') or exit('Access Denied');?><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title><?php  echo $row['title']?></title>
  <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/active_theme/css/bootstrap.min.css">
  <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/active_theme/css/weui.min.css">
  <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/active_theme/css/public.css">
  <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/active_theme/css/index.css">
  <style id="dshow_style">
        body{position:fixed;width:100%}
        #body{visibility:hidden;opacity:0;transition:linear .4s}
    </style>
  <style>
.main{background:#ecc029;}
.main .countdown{background:#fff;}
.main .countdown span{color:#cb1a34;}
.main .student{background:#fff;}
.main .student ul li .more{background:#e37830;color:#fff;}
.main .buy{background:#fff;}
.main .title{color:#fff;}
.main .buy .list li{background:#f7eedf;}
.main .buy .list li .name span{color:#7f7f81;}
.main .buy .list li .pay{color:#8b8786;}
.main .buy .list li .pay span{color:#e20113;}
.main .rank{background:#f6f6f6;}
.main .rank .rank-list li{background:#fff;}
.main .rank .rank-list li .one{color:#c9161c;}
.main .rank .rank-list li .two{color:#d53324;}
.main .rank .rank-list li .three{color:#994a2b;}
.main .rank .rank-list li .four{color:#221715;}
.main .rank .rank-list .name span{color:#6e6e6e;}
.main .rank .rank-list .name span .money{color:#e30011;}
.register-bg{background:rgba(8,4,4,0.6);}
.register .c{color:#ccc;background:#fff;border:1px solid #ccc;}
.register-form div p{color:#fff;}
.register-form div input{border:1px solid #3daada;}
.register-form .submit{background:#f4d339;color:#a44723;box-shadow:1px 2px #a44723;}
.success-bg{background:rgba(8,4,4,0.6);}
.success .share{background:#f4d339;color:#a44723;box-shadow:1px 2px #a44724;}
.share-main{background:rgba(8,4,4,0.6);}
.share-main .arrow p{color:#fff;}
.share-con .way .line{border-bottom:1px solid #fff;}
.share-con p{color:#fff;}
.share-con .cut,.post .del{color:#fff;border-bottom:1px solid #fff;}
.post{background:rgba(8,4,4,0.6);}
.post .post-con .post-main .post-title{background:#fff;}
.post .post-con .post-main .post-code{background:#fff;}
.post .post-con .post-main .post-code p{color:#654840;}
.some .foot{background:rgba(8,4,4,0.4);}
.some .foot .person p{color:#fff;}
.some .foot .rule{background:#38a637;}
.some .foot .apply{background:#f49f1a;}
.some .foot button{color:#fff;}
  </style>
</head>
<body>
<img src="<?php  echo tomedia($row['cover']);?>" style="display:none">
<div id="body">
<!-- head -->
    <div class="head">
        <img src="<?php  echo tomedia($row['cover']);?>" alt="">
    </div>
<!-- head -->
<!-- main -->
    <div class="main">
        <div class="countdown">
            <p><b>参与人数：<?php  echo robot($viewers_all, 'view', $row['id'], 'count')?></b>&emsp;<b>浏览人数：<?php  echo robot($row['views'], 'view', $row['id'], 'count2')?></b></p>
            <?php  if($time < 0) { ?>
            活动已结束
            <?php  } else { ?>
            距离活动结束还有：<span id="count"><span class="viewtime-day"></span>天<span class="viewtime-hour"></span>时<span class="viewtime-minute"></span>分<span class="viewtime-second"></span>秒</span>
            <?php  } ?>
        </div>
        <!-- student -->
        <div class="student">
            <p>已报学员</p>
            <ul class="clearfix">
                <?php  if(is_array($viewers)) { foreach($viewers as $index => $viewer) { ?>
                <li>
                    <img src="<?php  echo $viewer['avatar'];?>" alt="">
                    <p class="nickname"><?php  echo $viewer['name'];?></p>
                </li>
                <?php  } } ?>
                <?php  if($index == 27) { ?>
                <li>
                    <p class="more">+</p>
                    <p class="nickname"></p>
                </li>
                <?php  } ?>
            </ul>
            
        </div>
        <!-- student -->
        <!-- buy -->
        <?php  if($row['buyer_show_number'] > 0) { ?>
        <div class="buy">
            <div class="title">购买记录</div>
            <div class="clearfix">
                <p class="number fr">人数：<?php  echo robot($row['register'], 'order', $row['id'], 'count')?>人</p>
            </div>
            <div id="reg-box" style="height:<?php echo count($regs) == 0 ? 125 : ($row['buyer_show_number'] * 62)?>px;position:relative;overflow:hidden">
            <ul class="list" id="regs" style="position:absolute;top:0;width:100%;">
                <?php  if(is_array($regs)) { foreach($regs as $reg) { ?>
                <li style="width:100%">
                    <img class="fl" src="<?php  echo $reg['avatar'];?>" alt="">
                    <div class="name fl">
                        <p><?php  echo $reg['nickname'];?></p>
                        <span><?php  echo date('m/d H:i:s', $reg['create_time'])?></span>
                    </div>
                    <p class="pay fr">已支付<span><?php  echo $reg['price'];?></span>元</p>
                </li>
                <?php  } } ?>
                <?php  if(empty($regs)) { ?>
                    <p class="reg-none">暂无记录</p>
                <?php  } ?>
            </ul>
            </div>
        </div>
        <?php  } ?>
        <!-- buy  -->
        <!-- rank -->
        <?php  if($row['redpack_show_number'] > 0 && !empty($ranks)) { ?>
        <div class="rank">
            <div class="title">红包排行榜</div>
            <ul class="rank-list">
                <?php  $index = 0?>
                <?php  if(is_array($ranks)) { foreach($ranks as $key => $rank) { ?>
                <?php  $index += 1?>
                <li>
                    <p class="num <?php  if($index == 1) { ?>one<?php  } else if($index == 2) { ?>two<?php  } else if($index == 3) { ?>three<?php  } else { ?>four<?php  } ?> fl"><?php  echo $index;?></p>
                    <img class="fl" src="<?php  echo tomedia($rank['avatar']);?>">
                    <div class="name fr">
                        <p><?php  echo $rank['username'];?></p>
                        <span>已获得红包<span class="money"><?php  echo $rank['rewards'];?></span>元</span>
                    </div>
                </li>
                <?php  } } ?>
            </ul>
        </div>
        <?php  } ?>
        <!-- rank -->
        <!-- live -->
        <div class="live">
            <?php  echo $row['content'];?>
        </div>
        <!-- live --> 
    </div>

<!-- main -->
<!-- register -->

    <div class="register-bg">
       <div class="register">
            <span class="c">x</span>
            <form class="register-form" name="form" action="<?php  echo purl('createOrder')?>" method="post" id="form">
                <input type="hidden" name="pid" value="<?php  echo $row['id'];?>">
                <input type="hidden" name="order_sn" value="<?php  echo $order['order_sn'];?>">
                <input type="hidden" name="oid" value="<?php  echo $_GPC['oid']?>">
                <?php  $order && $order['joininformation'] = json_decode($order['joininformation'], true)?>
                <?php  if(empty($order)) { ?>
                <?php  if(is_array($row['joininformation'])) { foreach($row['joininformation'] as $jim) { ?>
                <div class="name">
                    <p><?php  echo $jim['name'];?></p>
                    <input type="text" name="joininformation[<?php  echo $jim['name'];?>]" autocomplete="true">
                </div>
                    <?php  } } ?>
                <?php  } else { ?>
                    <?php  if(is_array($order['joininformation'])) { foreach($order['joininformation'] as $ojim) { ?>
                <div class="phone">
                    <p><?php  echo $ojim['name'];?></p>
                    <?php  if(is_array($row['joininformation'])) { foreach($row['joininformation'] as $jim) { ?>
                        <?php  if($ojim['name'] == $jim['name']) { ?>
                            <input type="text" name="mobile" autocomplete="true" value="<?php  echo $ojim['value'];?>" disabled="disabled">
                        <?php  } ?>
                    <?php  } } ?>
                </div>
                <?php  } } ?>
                <?php  } ?>
                <button class="submit" type="submit" id="btn">提交</button>
            </form>
        </div>
    </div>
    
<!-- register -->
<!-- success -->
    <div class="success-bg">
        <div class="success" id="success">
            <button class="share">
                分享领好礼
            </button>
        </div>
    </div>
    
<!-- success -->
<!-- share -->
    <div class="share-main">
        <div class="arrow clearfix">
            <p>点击右上角分<br>享给微信好友</p>
            <img class="fr" src="<?php echo WEB_RESOURCE;?>/active_theme/images/share5.png" alt="">
        </div>
        <div class="share-con">
            <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/share1.png" alt="">
            <div class="way clearfix">
                <div class="line line-l fl"></div>
                <p>分享方式</p>
                <div class="line line-r fr"></div>
            </div>
            
            <div class="con-detail clearfix">
                <div class="friend fl">
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/share3.png" alt="">
                    <p>微信好友</p>
                </div>
                <div class="space fr">
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/share4.png" alt="">
                    <p>朋友圈</p>
                </div>

            </div>
            <p class="cut">取消</p>
        </div>
    </div>
<!-- share -->
<!-- post -->
    <div class="post">
        <div class="post-con">
            <?php  if($row['design_status'] == 3 || $row['design_status'] == 4) { ?>
            <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/loading5.gif" id="posters" style="width:100%">
            <?php  } else if($row['design_status'] == 2) { ?>
            <img src="<?php  echo purl('createdesign', ['pid'=>$row['id'], 'oid'=>$order['id'], 'rand'=>random(20)])?>" id="posters" style="width:100%"/>
            <?php  } ?>
            <!-- <div class="post-main">
                <div class="post-title clearfix">
                    <div class="user fl">
                        <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/2.png" alt="">
                        <p>1234512345</p>
                    </div>
                    <p class="title-con">
                        这个活动太优惠了，快来看看吧
                    </p>
                </div>
                <div class="post-code">
                    <p class="code-title">
                        轻盈画室，1028元精品课程，疯狂砍价只需99元
                    </p>
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/post-code.png" alt="">
                    <span>长按识别二维码进入活动</span>
                </div>
            </div> -->
        </div>
        <p class="del">取消</p>
    </div>
<!-- post -->
<!-- modal -->
    <div class="modal" id="rule-detail">
        <div class="modal-content">
            <div class="modal-header" style="padding: 0 15px;">活动规则</div>
            <div class="modal-body align-center" style="position:relative">
                <?php  echo $row['active_rule'];?>
            </div>
            <div class="modal-footer"><a href="javascript:;" class="modal-close">关闭</a></div>
        </div>
    </div>
<!-- modal -->
<!-- modal -->
    <div class="modal" id="shareqrcode">
        <div class="modal-content">
            <div class="modal-header" style="padding: 0 15px;">我的二维码</div>
            <div class="modal-body align-center" style="position:relative">
                <img src="<?php  echo purl('pinqrcode', ['pid'=>$row['id'], 'oid'=>$order['id'], 'rand'=>random(20)])?>" class="media-shareimg2" style="width:100%">
                <p style="font-size:12px;line-height:18px;padding:20px;color:#888">* 参与时请向工作人员提供此二维码</p>
                <?php  if($order['is_verifier'] == 1) { ?>
                <div style="position:absolute;top: 40%;left: 50%; transform: translate(-50%, -50%);padding: 14px 32px;background: rgba(0,0,0,.8);border-radius: 5px;color: #f0f0f0;line-height: 18px;font-size: 18px;font-weight: bold;border: 1px solid #f0f0f0;">已核销</div>
                <?php  } ?>
            </div>
            <div class="modal-footer"><a href="javascript:;" class="modal-close">关闭</a></div>
        </div>
    </div>
<!-- modal -->
<!-- some icon -->
    <div class="some">
        <?php  if($row['attract_status'] == 1) { ?>
            <?php  if($row['attract_type'] == 2) { ?>
            <a class="top" href="<?php  echo $row['attract_value_link'];?>"><?php  echo $row['attract_title'];?></a>
            <?php  } else { ?>
            <a class="top" href="<?php  echo purl('attract', array('pid'=>$row['id']))?>"><?php  echo $row['attract_title'];?></a>
            <?php  } ?>
        <?php  } ?>

        <div class="some-btn">
            <?php  if(!empty($row['bgm'])) { ?>
            <div class="btn-audio">
                <a href="javascript:;" class="music ">
                    <img class="btn-music active btn-ani" src="<?php echo WEB_RESOURCE;?>/active_theme/images/3.png" alt="">
                    <img class="btn-music" src="<?php echo WEB_RESOURCE;?>/active_theme/images/33.png" alt="">
                </a>
                <audio id="music" loop="loop">
                    <source src="<?php  echo tomedia($row['bgm']);?>" type="audio/mpeg" />
                </audio>
            </div>
            <?php  } ?>
            <a href="javascript:;" class="personal">
                <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/7.png" alt="">
            </a>
          	<?php  if($row['design_status'] != 1) { ?>
            <a href="javascript:;" class="recommend">
                <img class=" recommend-ani" src="<?php echo WEB_RESOURCE;?>/active_theme/images/8.png" alt="">
            </a>
          	<?php  } ?>
            <div class="btn-r">
                <a href="<?php  echo purl('infringement')?>" class="conplaint">
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/4.png" alt="">
                </a>
                <a href="javascript:;" class="s-share share hide">
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/6.png" alt="">
                </a>
                <?php  if(!empty($row['service_tel'])) { ?>
                <a href="tel:<?php  echo $row['service_tel'];?>" class="contect">
                    <img src="<?php echo WEB_RESOURCE;?>/active_theme/images/5.png" alt="">
                </a>
                <?php  } ?>
                <?php  if(is_array($row['floatMap'])) { foreach($row['floatMap'] as $float) { ?>
                <?php  if(!empty($float)) { ?>

                    <?php  if($float['status'] == 1) { ?>
                    <a class="self" href="<?php  echo $float['link'];?>"><img src="<?php  echo tomedia($float['image']);?>" style="width:100%;height:100%"></a>
                    <?php  } ?>
                    <?php  if($float['status'] == 2) { ?> 
                    <div class="toptheme">
                        <div class="toptheme-having">
                            <i class="close weui-icon-cancel" onclick="this.parentElement.parentElement.parentElement.removeChild(this.parentElement.parentElement)"></i>
                            <a href="<?php  echo $float['link'];?>"><img src="<?php  echo tomedia($float['image']);?>" style="width:100%;height:100%"></a> 
                        </div>
                    </div>
                    <?php  } ?>
                <?php  } ?>
            <?php  } } ?>
            </div>
            
        </div>
        <div class="foot clearfix">
            <div class="person">
                <img class="img-responsive" src="<?php  echo $avatar;?>" alt="">
                <p><?php  echo $nickname;?></p>
            </div>
            <button class="rule fl">活动规则</button>
            <?php  if($time <= 0) { ?>
                <?php  if($buyed && $row['is_cav'] == 2) { ?>
                    <button class="fr erweima">我的核销码</button>
                <?php  } else { ?>
                    <button class="fr">活动结束</button>
                <?php  } ?>
            <?php  } else if($buyed) { ?>
                <?php  if($row['is_cav'] == 2) { ?>
                    <button class="fr erweima">我的核销码</button>
                <?php  } else if($row['design_status'] != 1) { ?>
                    <button class="fr c-share">点击分享</button>
                <?php  } else { ?>
                    <button class="fr success-in">参与成功</button>
                <?php  } ?>
            <?php  } else { ?>
                <?php  if(empty($order)) { ?>
                    <button class="apply fr">我要参与</button>
                <?php  } else { ?>
                    <?php  if($order['status'] != 2) { ?>
                        <button class="apply fr">立即支付</button>
                    <?php  } else { ?>
                        <button class="fr c-share">点击分享</button>
                    <?php  } ?>
                <?php  } ?>
            <?php  } ?>
        </div>
    </div>
</div>
<!-- some icon -->


    <script src="<?php echo WEB_RESOURCE;?>/active_theme/js/jquery.min.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/active_theme/js/bootstrap.min.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/active_theme/js/tool.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/library/marque.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/posters.js"></script>
    <script>
        var can_submit = false;
        $.fn.extend({
            dshow: function() {
                $(this).css({
                    'transition': 'linear .2s',
                    'visibility': 'visible',
                    'opacity': '1'
                });
                $('body').css('position', 'relative');
                $('#dshow_style').remove();
            }
        });
        
        wx.ready(function() {
            // 展示页面
            $('#body').dshow();

            <?php  echo js_share($row["share_text"], $row["title"], $domainurl, '', ["pid"=>$row["id"], "oid"=>$_GPC["oid"]])?>

            $(function() {

                   
                if($('.s-share').hasClass('hide') && $('.contect').hasClass('hide')) {
                    $('.self').css('top', '100px');
                }else if($('.s-share').hasClass('hide')) {
                    $('.contect').css('top', '100px');
                    $('.self').css('top', '160px');
                }
                else {
                    $('.self').css('top', '220px');
                }
                
            
                $('.toptheme').on('click', function() {
                    $(this).hide();
                })

                var audio = document.getElementById('music');
                // $('.btn-music').click(function() {
                //     if(audio.paused) {
                //         $('.btn-music').addClass('btn-ani');
                //         audio.play();
                //         return;
                //     } else {
                //         $('.#btn-music').removeClass('btn-ani');
                //         audio.pause();
                //     }
                // });
                
                <?php  if(!empty($row['bgm'])) { ?>
                audio.play();
                <?php  } ?>
                $('.btn-music').on('click', function() {
                    if(audio.paused) {
                        audio.play();
                    } else {
                        audio.pause();
                    }
                    $(this).removeClass('active').siblings().addClass('active');
                });
                $('.apply').on('click', function() {
                    <?php  if($row['joininformation_status'] == 2 || empty($row['joininformation'])) { ?>
                        // 没有数据直接提交
                        // can_submit = true;
                        $('#form').submit();
                    <?php  } else { ?>
                        $('.register-bg').css('display', 'block');
                    <?php  } ?>

                });
                //
                $('.more').on('click', function() {
                    $('.register-bg').css('display', 'block');
                });
                $('.c').on('click', function() {
                    $('.register-bg').css('display', 'none');
                });
                //$('#submit').on('click', function() {
                //     $('.register-bg').css('display', 'none');
                //     $('.success-bg').css('display', 'block');
                // });
                $('.share').on('click', function() {
                    $('.success-bg').css('display', 'none');
                    share();
                });
                $('.recommend').on('click', function() {
                    share();
                });
                $('.friend').on('click', function() {
                    $('.arrow').css('display', 'block');
                });
                $('.space').on('click', function() {
                    $('.share-main').css('display', 'none');
                    $('.post').css('display', 'block');
                    $('.arrow').css('display', 'none');
                });
                $('.c-share').on('click', function() {
                    $('.post').css('display', 'block');
                })
                $('.cut').on('click', function() {
                    $('.share-main').css('display', 'none');
                });
                $('.del').on('click',function() {
                    $('.post').hide();
                });
                // $('#form').on('submit', function() {
                //     $('#submit').prop('disabled', true);
                //     $.post($(this).prop('action'), $(this).serialize(), function(res) {
                //         if(res.code == 1) {
                //             $('.register-bg').css('display', 'none');
                //             $('.success').css('display', 'block');
                //             location.reload();
                //         }else {
                //             alert(res.msg);
                //         }
                //         $('#submit').prop('disabled', false);
                //     }).fail(function(e) {
                //         alert('服务器繁忙，请稍后再试');
                //         $('#submit').prop('disabled', false);
                //     });
                //     return false;
                // });

                $('#form').on('submit', function() {
                    if(can_submit) {
                        return true;
                    }
                    $.post('<?php  echo purl("createOrder")?>', $('#form').serialize(), function(res) {
                        if(res.errno != 0) {
                            alert(res.message);
                            return false;
                        }

                        // 推广员下单，不进行支付
                        if(res.data.type == 3) {
                            alert('报名成功！');
                            location.reload();
                            return ;
                        }

                        var order_sn = res.data.order_sn;
                        var price = res.data.price;
                        var pay_url = res.data.pay_url;
                        
                        $('#form').prop('action', pay_url + '/app/<?php  echo substr(purl("pay", $_GET), 2)?>&order_sn='+order_sn);
                        can_submit = true;
                        $('#form').submit();

                    });
                    return false;
                });


                function share() {
                    $('.share-main').show();
                }
            
                changeViewTime('<?php  echo $time;?>','#count');
                marque('#regs', 62, '<?php  echo $row["buyer_show_number"];?>', 3);
                $('.rule').on('click', function() {
                    $('#rule-detail').addClass('modal-show');
                });
                $('.erweima').on('click', function() {
                    $('#shareqrcode').addClass('modal-show');
                });
                $('.modal-close').on('click', function() {
                    $(this).parents('.modal').removeClass('modal-show');
                });
                
                <?php  if($row['design_status'] == 3 || $row['design_status'] == 4) { ?>
                $("#posters").posters("<?php  echo purl('createdesign', ['pid'=>$row['id'], 'oid'=>$order['id'], 'rand'=>random(20)])?>", function(img) {
                    $('#posters').prop('src', img);
                });
                <?php  } else if($row['design_status'] == 2) { ?>
                // 动态图片转为可保存图片（ios端兼容）
                $('#posters').prop('src', getBase64Image($('#posters')[0]));
                     
                function getBase64Image(img) {
                    var canvas = document.createElement("canvas");
                    canvas.width = img.width;
                    canvas.height = img.height;
                    var ctx = canvas.getContext("2d");
                    ctx.drawImage(img, 0, 0, img.width, img.height);
                    var dataURL = canvas.toDataURL("image/png");
                    return dataURL // return dataURL.replace("data:image/png;base64,", ""); 
                }
                 <?php  } ?>
            })
})
                
        
        
        
        
    </script>
  
<script>;</script><script type="text/javascript" src="http://www.onfinger.cn/app/index.php?i=3&c=utility&a=visit&do=showjs&m=szxh_activeplus"></script></body>
</html>